<template>
	<view class="share">
		<view class="header_box flex">
			<view class="share_ipt flex">
				<input class="ipt s24 family f500" type="text" value="" v-model="keyWord"
					placeholder-style="color:#cccccc;" placeholder="店家名称" />
				<image class="share_icon" src="../static/sousuo_icon.png" mode=""></image>
			</view>
			<view class="share_btn s26 family f500 txtali" @click="screen">
				搜索
			</view>
		</view>
		<view class="list_box">
			<view class="list_txt s28 fblod familytow" v-for="(item,index) in storeNamelist" :key="item.id"
				@click="onBack(item.id,item.shopname)">
				{{item.shopname}}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				keyWord: '',
				storeNamelist: []
			}
		},
		onLoad() {

		},
		methods: {
			// 点击搜索
			screen() {
				this.getStoreList()
			},
			// 获取搜索的列表
			getStoreList() {
				this.$request({
					url: 'shop/lists',
					data: {
						search: this.keyWord
					}
				}).then(res => {
					if (res.statusCode == 200) {
						this.storeNamelist = res.data.data.data
					}
				})
			},
			// 返回上一页并修改参数
			onBack(id, name) {
				let pages = getCurrentPages();
				let nowPage = pages[pages.length - 1];
				let prevPage = pages[pages.length - 2];
				prevPage.$vm.storeId = id;
				prevPage.$vm.storeName = name;
				uni.navigateBack({
					delta: 1
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.share {
		overflow: hidden;

		.header_box {
			margin-top: 50upx;

			.share_ipt {
				width: 538upx;
				height: 68upx;
				background: #F3F3F3;
				border-radius: 8upx 8upx 8upx 8upx;
				margin-left: 32upx;

				.ipt {
					width: 460upx;
					height: 68upx;
					background: #F3F3F3;
					border-radius: 8upx 8upx 8upx 8upx;
					padding-left: 78upx;
					color: #000;
				}

				.share_icon {
					width: 40upx;
					height: 40upx;
					position: absolute;
					left: 56upx;
					margin-top: 16upx;
				}
			}

			.share_btn {
				width: 116upx;
				height: 68upx;
				background: #E0A76D;
				border-radius: 34upx 34upx 34upx 34upx;
				line-height: 68upx;
				color: #FFFFFF;
				margin-left: 32upx;
			}
		}

		.list_box {
			margin-left: 32upx;
			margin-top: 40upx;

			.list_txt {
				color: #333333;
				margin-bottom: 30upx;
			}
		}
	}
</style>
